Skip to main content

Systemd

Updated Mar 27, 2021 ·

Tasks

  1. Make sure httpd service is automatically started.
  2. Edit its config such that on failure, it will continue afte 1 minute.

Solution

1. Auto-start httpd

Enable the httpd service:

sudo systemctl enable httpd

Start the httpd service:

sudo systemctl start httpd

2. Configure httpd

Create a systemd override file for httpd:

sudo systemctl edit httpd

Add the following lines to the override file:

[Service]
Restart=on-failure
RestartSec=60

This will ensure that the httpd service restarts after 1 minute if it fails. Save and exit the editor. Reload the systemd manager configuration:

sudo systemctl daemon-reload

Restart the httpd service to apply the changes:

sudo systemctl restart httpd